#include <libpq-fe.h>
#include <stdlib.h>
#include "DlgDBSetPara.h"
#pragma  comment(lib,"libpq.lib")
#pragma once
#define  DATABASE_CONNECTOK 0
#define DATABASEE_HOSTNAME_ERROR 1
#define  DATABASE_PASSWORD_ERROR 2
#define  DATABASE_MOTION_NOT_EXIST_ERROR 3
#define  DBExecError  (WM_USER+113)
#define  DBINQUIRE_MSG (WM_USER+126)
#define InquireFinish (WM_USER+139)
#define Initial_Finish (WM_USER+152)
#define NOINQUIREMSG (WM_USER+165)
#define LISTSTATUS (WM_USER+178)
#define LISTPREV (WM_USER+179)
#define LISTNEXT (WM_USER+180)


class ConnectToDB
{
private:
	PGconn *m_conn;
	PGresult *m_pgresult;
	char* m_pHostName;
	char* m_pPsw;
	char* m_pDBName;
	BOOL m_DBExecFlag;
public:
	ConnectToDB(void);
	ConnectToDB(char* host,char* dbname,char* psw);
	~ConnectToDB(void);
	void SqlConnect();
	void SwitchEncoding(char* code_lan);
	void SqlExec(char * query_string);
	int SqlCheckConn();
	void SqlExit();
	char*m_pErrMsg;
	void SetDBMsg(char* host,char* dbname,char* dbpsw);
	char* GetDBHostName();
	char* GetDBName();
	char* GetDBPsw();
	PGresult* GetPGresult();
};
